Release 10.1A: OpenEdge Data Management:
SQL Development
Outer joins
An outer join between two tables returns more information than a corresponding inner join. An outer join returns a result table that contains all the rows from one of the tables even if there is no row in the other table that satisfies the join condition.
In a left outer join, the information from the table on the left is preserved: the result table contains all rows from the left table even if some rows do not have matching rows in the right table. Where there are no matching rows in the right table, SQL generates
NULLvalues.In a right outer join, the information from the table on the right is preserved. The result table contains all rows from the right table even if some rows do not have matching rows in the left table. Where there are no matching rows in the left table, SQL generates
NULLvalues.SQL uses two forms of syntax to support outer joins:
- In the
WHEREclause of a query expression, specify the outer join operator ( + ) after the column name of the table for which rows will not be preserved in the result table. Both sides of an outer join search condition in aWHEREclause must be simple column references. This syntax allows both left and right outer joins.- For left outer joins only, in the
FROMclause, specify theLEFT OUTER JOINclause between two table names, followed by a search condition. The search condition can contain only the join condition between the specified tables.Full (two-sided) outer joins are not supported. Right outer joins are only supported using the outer join operator in the
WHEREclause. The keywordsRIGHT OUTER JOINare not supported currently.This is the syntax for a
from_clause_outer_join:
This is the syntax for a
where_clause_outer_join:
The following example shows a left outer join:
The query requests information about all the customers and their orders. Even if there is not a corresponding row in the
Ordertable for each row in theCustomertable,NULLvalues are displayed for theOrder.OrdernumandOrder.Orderdatecolumns.The query produces the results table shown in Example 6–12.
Example 6–13 illustrates outer join syntax.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |